﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Dao;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Weblications.Sango.Protocol.mission;
using Pixysoft.Weblications.Sango.Protocol;
using Pixysoft.Weblications.Sango.Constant;

namespace Pixysoft.Weblications.Sango.Command.mission
{
    partial class SangoMissionHandler
    {
        public mission_dailylist mission_dailylist()
        {
            string userCode = SangoManager.Authentication();

            mission_dailylist response = ReflectionManager.CreatePojo<mission_dailylist>();
            response.Succeed = false;

            Entities.Usr_Profile profile = UsrProfileDao.getUsrProfile(userCode);
            Entities.Usr_Mission activity = MissionDao.getMission(userCode);
            Entities.Usr_Building building = UsrBuildingDao.getUserBuilding(userCode, CtiBuildingTypecodeCollection.ISI);

            if (MissionFormular.isMissionDailyWeeklyRefresh(activity))
            {
                MissionDao.refreshDailyMissionWeekly(activity);
                SettingHelper.GetNoebe().EntityNoebeCommand.Update(activity);
            }
            else if (MissionFormular.isMissionDailyDailyRefresh(activity))
            {
                MissionDao.refreshDailyMissionDaily(activity);
                SettingHelper.GetNoebe().EntityNoebeCommand.Update(activity);
            }

            response.acceptlist = MissionFacade.ToAcceptMissions(profile, activity, building.Buildinglevel);
            response.newlist = MissionFacade.ToNewMissions(profile, activity, building.Buildinglevel);
            response.todaydone = (activity.Dailymissioncount);
            response.todaymax = (MissionFormular.default_max_dailymission);
            response.levelmax = MissionDao.getDailyMissionMaxLevel(activity);
            response.Succeed = true;
            return response;
        }


    }
    public interface mission_dailylist : ISangoResponse
    {
        List<mission_daily> acceptlist { get;set;}
        List<mission_daily> newlist { get;set;}
        long todaydone { get;set;}
        long todaymax { get;set;}
        long levelmax { get;set;}
    }
}
